import Vue from 'vue'
import VueRouter from "vue-router";
import index from "../components/index"


Vue.use(VueRouter)

const router = new VueRouter({
    mode: 'history',
    routes: [
        {
            path: '/index',
            component: index
        }

    ]
})
// 路由守卫
// router.beforeEach((to, from, next) => {
//     // to.path 获得到的是路由的path
//     // http://localhost:8080/login  -> /login
//     // 如果用户是到登录页面或者 localStorage中有 token
//     if(to.path === '/login'||to.path ==='/search'|| to.path ==='/index'||to.path ==='/introduction' || localStorage.getItem('token')) {
//         next()
//     }else {
//         // next() 中的参数是路由中的 path
//         next('/login')
//     }
// })

export default router